package com.tencent._05_tran;

import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;

/**
 * @BelongsProject: rocketmq-test
 * @BelongsPackage: cn.itsource._05_tran
 * @Author: Director
 * @CreateTime: 2022-07-23 21:48
 * @Description: 定义事务监听器
 * @Version: 1.0
 */
public class MyTranListener implements TransactionListener {

    @Override
    public LocalTransactionState executeLocalTransaction(Message message, Object o) {
        System.out.println("执行了业务，保存了本地事务！");
        // 保存成功
        return LocalTransactionState.COMMIT_MESSAGE;
    }

    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt messageExt) {
        System.out.println("本地事务查询：提交成功！");
        return LocalTransactionState.COMMIT_MESSAGE;
    }
}
